package com.hurui.xiaoming.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hurui.xiaoming.R;
import com.hurui.xiaoming.bean.Li_profit_Result;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/27.
 */

public class ProfitsAdapter extends BaseAdapter {
    private final LayoutInflater inflater;
    List<Li_profit_Result.DataBean> list;

    public ProfitsAdapter(Context context) {
        list=new ArrayList<>();
        inflater = LayoutInflater.from(context);
    }

    public void notifyData(List<Li_profit_Result.DataBean> lists){

        lists.addAll(lists);
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.e("ccc", "getView: "+list.get(position).toString());
        Holder holder;
        if (convertView==null){
            holder=new Holder();
            convertView=inflater.inflate(R.layout.profit_item,parent,false);
            holder.profit_info = ((TextView) convertView.findViewById(R.id.profit_info_tv));
            holder.profit_money = ((TextView) convertView.findViewById(R.id.profit_money_tv));
            holder.profit_time = ((TextView) convertView.findViewById(R.id.profit_time_tv));

            convertView.setTag(holder);
        }else {
            holder= (Holder) convertView.getTag();
        }
        holder.profit_money.setText(list.get(position).getOi_jkprice());
        return convertView;
    }
    class Holder{
        public TextView profit_info,profit_time,profit_money;
    }
}
